<?php

/**
 * This is the model class for table "mayzus_user".
 *
 * The followings are the available columns in table 'mayzus_user':
 * @property integer $id
 * @property integer $parent_id
 * @property integer $country_id
 * @property string $username
 * @property string $password
 * @property integer $status
 * @property string $exp_date
 * @property string $create_date
 * @property integer $is_login
 * @property integer $is_master
 * @property integer $account_type
 * @property string $number_of_account
 * @property integer $is_pva
 */
class MayzusUser extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return MayzusUser the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'mayzus_user';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('parent_id, country_id, status, is_login, is_master, account_type, is_pva', 'numerical', 'integerOnly'=>true),
			array('username, password', 'length', 'max'=>255),
			array('number_of_account', 'length', 'max'=>10),
			array('exp_date, create_date', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, parent_id, country_id, username, password, status, exp_date, create_date, is_login, is_master, account_type, number_of_account, is_pva', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'parent_id' => 'Parent',
			'country_id' => 'Country',
			'username' => 'Username',
			'password' => 'Password',
			'status' => 'Status',
			'exp_date' => 'Exp Date',
			'create_date' => 'Create Date',
			'is_login' => 'Is Login',
			'is_master' => 'Is Master',
			'account_type' => 'Account Type',
			'number_of_account' => 'Number Of Account',
			'is_pva' => 'Is Pva',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('parent_id',$this->parent_id);
		$criteria->compare('country_id',$this->country_id);
		$criteria->compare('username',$this->username,true);
		$criteria->compare('password',$this->password,true);
		$criteria->compare('status',$this->status);
		$criteria->compare('exp_date',$this->exp_date,true);
		$criteria->compare('create_date',$this->create_date,true);
		$criteria->compare('is_login',$this->is_login);
		$criteria->compare('is_master',$this->is_master);
		$criteria->compare('account_type',$this->account_type);
		$criteria->compare('number_of_account',$this->number_of_account,true);
		$criteria->compare('is_pva',$this->is_pva);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}